<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加乐谱</title>
</head>
<body>

<form class="layui-form" lay-filter="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    乐谱名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入乐谱名称"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    作者名称</label>
                <div class="layui-input-block">
                    <input type="text" name="author" lay-verify="required" autocomplete="off" placeholder="请输入作者名称"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <text style="color:red;">图片尺寸建议 1:1比例</text>
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    作者头像</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="avatar"
                         data-dir="xm_game/skym/music/avatar"
                         data-accept="image"
                         data-type="ali-oss"
                         data-layVerify="required"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>
            <div class="layui-form-item">
                <text style="color:red;">图片尺寸建议 1:1比例</text>
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    封面图</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="cover"
                         data-dir="xm_game/skym/music/cover"
                         data-accept="image"
                         data-type="ali-oss"
                         data-layVerify="required"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    bpm</label>
                <div class="layui-input-block">
                    <input type="number" name="bpm" lay-verify="required" autocomplete="off" placeholder="请输入bpm"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    音高</label>
                <div class="layui-input-block">
                    <input type="text" name="pitch" lay-verify="required" autocomplete="off" placeholder="请输入音高"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    基础节拍</label>
                <div class="layui-input-block">
                    <input type="number" name="base_beat" lay-verify="required" autocomplete="off" placeholder="请输入基础节拍"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    节拍</label>
                <div class="layui-input-block">
                    <input type="text" name="time_signature" lay-verify="required" autocomplete="off" placeholder="请输入节拍"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    规模</label>
                <div class="layui-input-block">
                    <input type="number" name="scale" lay-verify="required" autocomplete="off" placeholder="请输入规模"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    标签</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="label_id"
                         data-sourceType="route"
                         data-source="/admin.skym.label/index"
                         data-valueField="id"
                         data-textField="name"
                         data-radio="true"
                         data-placeholder="请选择标签"
                    ></div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">  <text title="必填项" style="color:red;">*</text>
                        乐谱内容</label>
                    <div class="layui-input-block">
                        <textarea name="notes"  placeholder="请输入乐谱内容" class="layui-textarea" lay-verify="required"></textarea>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    if (localStorage.getItem("staticDomain")) {
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    } else {
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    }
</script>
<script>
    layui.use(['laytp'], function () {
        layui.form.on('submit(add)', function (data) {
            var btnAnim = layui.button.load({elem: $(this)});
            facade.ajax({
                route: '/admin.skym.music/add',
                data: data.field
            }).done(function (res) {
                if (res.code === 0) {
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function () {
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>